﻿import React, { Component } from 'react'
import PropTypes from 'prop-types'
import './DataList.css'

export default class extends Component {
    static propTypes = {
        dataset: PropTypes.array,
        currentData: PropTypes.object,
        selectData: PropTypes.func.isRequired
    }
    render() {
        return (
            <div>
                {this.props.dataset && this.props.dataset.map((d, idx) => (
                    <div
                        key={idx}
                        onClick={() => this.props.selectData(d)}
                        className={`data-item ${d === this.props.currentData ? 'focused-item' : ''}`}
                    >{d.title}</div>))
                }
            </div>
        )
    }
}